{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "view-in-github"
   },
   "source": [
    "<a href=\"https://colab.research.google.com/github/ayush-09/K-Means-Clustering/blob/master/Unsupervised_Learning_.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "WdGfBpUVoyJ_"
   },
   "source": [
    "# Unsupervised Learning Algorithm\n",
    "- Salaray Dataset from kaggle name salary.csv : https://www.kaggle.com/rsadiq/salary\n",
    "- K-means++ Clustering algoritm(k=3), I choose K-means++ instead instead of K-means because it doesnot chosse any random for centroid.\n",
    "k=3 is fit after check the wscc and silhouette score for each k value.\n",
    "- I plot both the graphs **Elbow Method** and **Silhoutte** for the best cluster value.\n",
    "- After made the model I will check the sum of square error of the first 10 iteration of the model by plot the graph."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "f2jVcjGfGpuA"
   },
   "source": [
    "## Connect with drive\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "iqQ8Pt17GpH7",
    "outputId": "ddb95c5b-fae4-427c-9167-4abc76fc538d"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mounted at /content/gdrive\n"
     ]
    }
   ],
   "source": [
    "from google.colab import drive\n",
    "\n",
    "drive.mount(\"/content/gdrive\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ALFYwu6oHUVU"
   },
   "source": [
    "## Import the libraries\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "id": "4jK_6EZqEnCv"
   },
   "outputs": [],
   "source": [
    "from sklearn.cluster import KMeans\n",
    "from sklearn.metrics import silhouette_score,silhouette_samples\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "from matplotlib import pyplot as plt\n",
    "import matplotlib.cm as cm\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "9rM8vR3kXzzy"
   },
   "source": [
    "## Visualize the data\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 195
    },
    "id": "uedCNPgSEnCw",
    "outputId": "dd3e2dac-e7e4-4975-fb6a-36180ee68f51"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>YearsExperience</th>\n",
       "      <th>Salary</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.1</td>\n",
       "      <td>39343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.3</td>\n",
       "      <td>46205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.5</td>\n",
       "      <td>37731</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>43525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2.2</td>\n",
       "      <td>39891</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   YearsExperience  Salary\n",
       "0              1.1   39343\n",
       "1              1.3   46205\n",
       "2              1.5   37731\n",
       "3              2.0   43525\n",
       "4              2.2   39891"
      ]
     },
     "execution_count": 4,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df=pd.read_csv(\"/content/gdrive/MyDrive/archive/Salary.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 282
    },
    "id": "BRp_Z0-6EnCx",
    "outputId": "aaaf49c0-a056-422b-a7aa-4348a7a17d3b"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x7f9eb3baab10>"
      ]
     },
     "execution_count": 5,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAD4CAYAAAAQP7oXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAZZ0lEQVR4nO3df4yd1X3n8fenNiRDumEgphSPTW01rlckbtfkCty1VEXQYIdEsWWh1G12cVMUq0rSZtuIxE6lUiXVeiJXS4OadWTFFNNFOKyXGqskcVzMKlJVE8ZMg8HEZRQKzAXiScyQVbACdr/7xz0D18Odmef+mue5z/28pNHce57z3Oc8CZ7vPed8z3MUEZiZmWXxC3k3wMzMeoeDhpmZZeagYWZmmTlomJlZZg4aZmaW2cK8G9BpixYtimXLluXdDDOznnLs2LEfR8Rlc9UrXdBYtmwZIyMjeTfDzKynSHo2Sz0PT5mZWWYOGmZmlpmDhpmZZeagYWZmmc0ZNCTdKemUpCcaHPuspJC0KL2XpDskjUl6XNLVdXW3SHo6/WypK3+fpOPpnDskKZVfKulwqn9Y0iWduWUzM2tVlp7GXcD66YWSlgI3AM/VFX8QWJF+tgK7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0bfBF4JSK+k2+rWnZ5RLyYXr8EXJ5nYzrgD4Bv5d2IVkjaAFQj4vtZz3HQmAeSfhH4P8B/i4if5t2eZkj6MHAqIo7l3ZY2LASuBnZFxGrgZxR/SOQ8adx/A7UAuBh4h6T/km+r2he1nP+ezfuX9GfUhqHvybstzZJ0EfAF4M+bOc9Bo8skXUAtYNwTEffn3Z4WrAU+IunfgH3AdZL+V75Nato4MB4RU728/dSCSC/5beCZiJiIiNeB+4H/nHObWvUjSVcApN+ncm5PSyT9PvBh4GPRmwvefpXal5Dvp3/fS4DHJP3ybCc5aHSRJFEbR38qIv5H3u1pRURsj4glEbGM2sTrkYjoqW+4EfES8LyklanoeuBEjk1qxXPAGkkXpf+urqfHJvPrHAS2pNdbgAdybEtLJK2nNmT7kYh4Ne/2tCIijkfEL0XEsvTvexy4Ov17mZGDRnetBf4rtW/n/5J+bsy7UX3qj4B7JD0O/Cfgv+fcnqakXtJ+4DHgOLV/u4V/jIWke4F/BlZKGpd0CzAMfEDS09R6UMN5tnEuM9zD3wD/ATic/l1/LddGZjDDfTT/Ob3ZqzIzszy4p2FmZpk5aJiZWWYOGmZmlpmDhpmZZeagYWZmmTlomJlZZg4aZmaW2f8HfTqskqXp90EAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light",
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(df['YearsExperience'],df['Salary'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "id": "k8kzph36Rj71"
   },
   "outputs": [],
   "source": [
    "X=df[['YearsExperience','Salary']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "q4Xgg5R_rcKM"
   },
   "source": [
    "## Calculate the WCSS and Silhouette Score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "8Y6xQrl8RbXU",
    "outputId": "ada348b3-660f-4534-d784-bc39080779ce"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cluster = 2, wcss=6062232833.744474, Silhouette= 0.7028572890853004\n",
      "Cluster = 3, wcss=2903864662.5549126, Silhouette= 0.6331618019952167\n",
      "Cluster = 4, wcss=1663816733.7989414, Silhouette= 0.6368549820565115\n",
      "Cluster = 5, wcss=894398887.721595, Silhouette= 0.6173381925348792\n",
      "Cluster = 6, wcss=652477856.6519287, Silhouette= 0.627089162952214\n",
      "Cluster = 7, wcss=441789859.79249996, Silhouette= 0.6421588941076305\n"
     ]
    }
   ],
   "source": [
    "wcss =[]\n",
    "silhouette=[]\n",
    "for i in range(2,8):\n",
    "    k_means = KMeans(n_clusters=i,init = 'k-means++', random_state=20)\n",
    "    k_means.fit(X)\n",
    "    wcss.append(k_means.inertia_)\n",
    "    pred = k_means.predict(X)\n",
    "    silhouette.append(silhouette_score(X,pred))\n",
    "    print(\"Cluster = {0}, wcss={1}, Silhouette= {2}\".format(i,k_means.inertia_,silhouette_score(X,pred)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "NGdx-zSDsJXU"
   },
   "source": [
    "## Ploting the Graphs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 295
    },
    "id": "_-31zovzLY2x",
    "outputId": "3c47cd93-c177-42f4-8178-c501177cf402"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEWCAYAAABsY4yMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXxU9b3/8dcnGyEBEiBhDTuyuaHGjcVdWWqrttXa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aB68p03AIjO7ONjGzOxY9sLMerj7p+5+B/AxoICXuCjgJVncBdQ/m+Z64Eozm0lsRtGRAGZ2jZlds5ftHwAyzOxT4FngCnevPsA+RwJnBttMZbczYNx9GbEPnlnBn9OCRc2BsUFtk4GfB88/A9wcHCjtQewDZ4SZzQBmAxfso46fmdms4PW2A68coG4RQLNJioikLI3gRURSlAJeRCRFKeBFRFKUAl5EJEUp4EVEUpQCXkQkRSngRURS1P8HA/h9xdFZmS0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light",
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(2,8),wcss)\n",
    "plt.title('Elbow Method')\n",
    "plt.xlabel('No. of clusters')\n",
    "plt.ylabel('wcss score')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 295
    },
    "id": "bgAtKjOAR1aF",
    "outputId": "9e23b406-b881-4076-f94f-95ad5db99442"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEWCAYAAAB8LwAVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3dd3hc1bnv8e+rZtlyt+SmkRsu2AYXSXQTWgBTDdgmlBRyciA5J0BIgHMgPSScy01uCCGQnJBKQktcAIOppjcDklzAveAi2cZVbrKt9t4/ZhsGRZbHtkZbmvl9nmcea/bsvec3Bs+rvdZea5m7IyIi0lBa2AFERKR1UoEQEZFGqUCIiEijVCBERKRRKhAiItIoFQgREWmUCoRIwMyuNrMXYp67mQ0Ofv6rmf0svHQiLU8FQlKOmY0zs7f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HsClwNHu7mbW1d0rzWxG8F5Tg/1eAr7h7svM7ATgt8CZwWkiwMnuXmdmTwHfdPe3gokp98aTQ0RXEJLUgtl5/wbc2OClk4BHgp//Dow7yKnGAQ8F51wMrAaGHuSYM4HfBcfUufv2OGNvJ/ol/iczuwyoarhD8EV/MjAlmCbm90SnUdlvirvXBT+/BdxtZjcCXd29Ns4ckuJUICQV3AN8DWhtawPU8tl/g9kAwRf48URnI70QaGwOpTSg0t3HxDyGx7y+e/8P7n4X8O9Ae+Ct/U1RIgejAiFJz923Av8kWiT2e5vozK4AVwNvHOQ0bwT7ETQt9QOWHOSYl4D/CI5JD1Y8i7UaGGFm7YIZds8K9u0IdAkmjfw2MDrYfyfQKfhMO4CPzGxycIyZ2WgaYWZHufsH7v5/gfcBFQiJiwqEpIpfArF3M90AfNXM5hOd0fdbAGb2DTP7RiPH/xZIM7MPgH8A17j7voO857eAM4JjSmlwB5K7ryVauD4M/pwTvNQJeDrI9ibwnWD7Y8CtQUfzUUQL1tfMbB6wAJhwgBw3mdmHwflqgGcPklsE0GyuIiJyALqCEBGRRqlAiIhIo1QgRESkUSoQIiLSKBUIERFplAqEiIg0SgVCREQa9f8Biy1qZsFrwNcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light",
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(2,8),silhouette)\n",
    "plt.title('Silhouette')\n",
    "plt.xlabel('No. of clusters')\n",
    "plt.ylabel('Silhouette score')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "rIeAHgsJsP-n"
   },
   "source": [
    "## Train the model\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "Zbzrurv3EnCx",
    "outputId": "213d54db-2fdd-43ea-99be-59445f77f141"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KMeans(algorithm='auto', copy_x=True, init='k-means++', max_iter=100,\n",
       "       n_clusters=5, n_init=10, n_jobs=None, precompute_distances='auto',\n",
       "       random_state=None, tol=0.0001, verbose=True)"
      ]
     },
     "execution_count": 10,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "km=KMeans(n_clusters=5, init='k-means++',max_iter=100,verbose=True)\n",
    "km"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Rtf4lXtDsUtB"
   },
   "source": [
    "## Prediction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "a_rjkpRYEnCy",
    "outputId": "6296e2f8-7255-46cd-f7e1-40d0e8d56389"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 944865214.6304046\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 944865214.6304046\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 1504371017.23425\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 1504371017.23425\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 1198190608.6271667\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 1198190608.6271667\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 1251859328.2879996\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 1158509896.5262141\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 1158509896.5262141\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 919084793.4247856\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 919084793.4247856\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 917097459.1652617\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 917097459.1652617\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 1570578612.1835585\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 1392384670.572329\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 1248208083.0671272\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 3, inertia 944865214.6304046\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 4, inertia 944865214.6304046\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 1053324728.9333895\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 944865214.6304046\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 944865214.6304046\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 944865214.6304046\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 944865214.6304046\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 1198190608.6271667\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 1198190608.6271667\n",
      "center shift 0.000000e+00 within tolerance 5.024411e+04\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,\n",
       "       2, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3], dtype=int32)"
      ]
     },
     "execution_count": 11,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_predicted=km.fit_predict(df[['YearsExperience','Salary']])\n",
    "y_predicted"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "rS6hTWw2EnCy",
    "outputId": "9067a9a4-d0ee-43d9-9d7d-e5d927a07606"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>YearsExperience</th>\n",
       "      <th>Salary</th>\n",
       "      <th>cluster</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.1</td>\n",
       "      <td>39343</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.3</td>\n",
       "      <td>46205</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.5</td>\n",
       "      <td>37731</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>43525</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2.2</td>\n",
       "      <td>39891</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2.9</td>\n",
       "      <td>56642</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>3.0</td>\n",
       "      <td>60150</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3.2</td>\n",
       "      <td>54445</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3.2</td>\n",
       "      <td>64445</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>3.7</td>\n",
       "      <td>57189</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>3.9</td>\n",
       "      <td>63218</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>4.0</td>\n",
       "      <td>55794</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>4.0</td>\n",
       "      <td>56957</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>4.1</td>\n",
       "      <td>57081</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>4.5</td>\n",
       "      <td>61111</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>4.9</td>\n",
       "      <td>67938</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>5.1</td>\n",
       "      <td>66029</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>5.3</td>\n",
       "      <td>83088</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>5.9</td>\n",
       "      <td>81363</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>6.0</td>\n",
       "      <td>93940</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>6.8</td>\n",
       "      <td>91738</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>7.1</td>\n",
       "      <td>98273</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>7.9</td>\n",
       "      <td>101302</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>8.2</td>\n",
       "      <td>113812</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>8.7</td>\n",
       "      <td>109431</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>9.0</td>\n",
       "      <td>105582</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>9.5</td>\n",
       "      <td>116969</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>9.6</td>\n",
       "      <td>112635</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>10.3</td>\n",
       "      <td>122391</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>10.5</td>\n",
       "      <td>121872</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>11.2</td>\n",
       "      <td>127345</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>11.5</td>\n",
       "      <td>126756</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>12.3</td>\n",
       "      <td>128765</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>12.9</td>\n",
       "      <td>135675</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>13.5</td>\n",
       "      <td>139465</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    YearsExperience  Salary  cluster\n",
       "0               1.1   39343        4\n",
       "1               1.3   46205        4\n",
       "2               1.5   37731        4\n",
       "3               2.0   43525        4\n",
       "4               2.2   39891        4\n",
       "5               2.9   56642        0\n",
       "6               3.0   60150        0\n",
       "7               3.2   54445        0\n",
       "8               3.2   64445        0\n",
       "9               3.7   57189        0\n",
       "10              3.9   63218        0\n",
       "11              4.0   55794        0\n",
       "12              4.0   56957        0\n",
       "13              4.1   57081        0\n",
       "14              4.5   61111        0\n",
       "15              4.9   67938        0\n",
       "16              5.1   66029        0\n",
       "17              5.3   83088        2\n",
       "18              5.9   81363        2\n",
       "19              6.0   93940        2\n",
       "20              6.8   91738        2\n",
       "21              7.1   98273        2\n",
       "22              7.9  101302        2\n",
       "23              8.2  113812        1\n",
       "24              8.7  109431        1\n",
       "25              9.0  105582        1\n",
       "26              9.5  116969        1\n",
       "27              9.6  112635        1\n",
       "28             10.3  122391        3\n",
       "29             10.5  121872        3\n",
       "30             11.2  127345        3\n",
       "31             11.5  126756        3\n",
       "32             12.3  128765        3\n",
       "33             12.9  135675        3\n",
       "34             13.5  139465        3"
      ]
     },
     "execution_count": 12,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['cluster']=y_predicted\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "OauQMQkrNiBO",
    "outputId": "e25a0b6e-b30a-49d6-9af4-984ea626cc49"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(array([0, 1, 2, 3, 4], dtype=int32), array([12,  5,  6,  7,  5]))\n"
     ]
    }
   ],
   "source": [
    "print(np.unique(km.labels_,return_counts= True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 297
    },
    "id": "wJQphFQNEnCy",
    "outputId": "731e78f4-24e4-4dd2-b94b-b196ca5dc08d"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Salary')"
      ]
     },
     "execution_count": 14,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAEGCAYAAACzYDhlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF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t0o6L23/laThtP0dSZ9OvaD7JJ2cyl+c3jEyuX3vkrRO0h3AxtTe+9K++eldKneld6n8VUnbv6Pn3tkznFYaQNJrJf1ruo/Nkl4y3XnMZrKg6AaYNYhLyGbZPw3cTra8znuUvdxqs6R/IVuL6y0R8VtJS4GbgN50/Elk7yl5WNKfAj+LiLfBgVcVTBiW9Ju0vSEi/ivQD3xf0sPABWTvMJrQERGvlvRG4HrgBGBgmvZNtONVEbEnrRg+YTXZis+vlXRIut7E6s8nAq8ke/XA94E3SNoM3AKcExF3SToM+M1054mIh2f3n9vajYONGRARv5Z0C/D/gD8HzpL0kbT7UKCL7C/jz0h6NfAs8PKSU2wu+Qt3K/D3ki4Hbo+I75XU65s8jBYRj0v6BPBt4D9GROm7Q25Kdb4r6bAUXE4nW+R0cvsgC2BTvXvkdOBVkt6ZvncCS8mC6+aI2Akg6d+AHmAceDQi7krX/2XaP915HGysLAcbs+fsTz8C/jQiHizdKem/A4+TvbFzHvDbkt2/ntiIiJ9IOgl4K/ApSRsj4tIZrr0M+AXZawBKTX6oGmXad0ppOyYRcH5ErJ90zJuA35UUPUv5vxemPI/ZTPzMxuyF1gPnlzy7ODGVd5L9a38/2UKp86c6WNLLgL0R8SXgCmZ4LUF6FnMm2XDWRyQtKdl9Tqrzx2TDV+Nl2jfTPf21sldXIOnlKv8iuAeBYyS9NtV/ibI3fc72PGaAezZmU/kk2VtG75U0j2yI6O3A54CvpIf532T6XsQy4ApJ+4FngL8u2Vf6zObnZK/N/gLw7oj4maQLgOslnZbq/FbSPcBBZG92LNe+cq4lGx67OwWp3ZR5rXJEPJ0SG/6XpBeRPa9582zPYzbBqc9mDaqeqdJmefMwmpmZ5c49GzMzy517NmZmljsHGzMzy52DjZmZ5c7BxszMcudgY2Zmufv/BMDqjhHDPZsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light",
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df1=df[df.cluster==0]\n",
    "df2=df[df.cluster==1]\n",
    "df3=df[df.cluster==2]\n",
    "df4=df[df.cluster==3]\n",
    "df5=df[df.cluster==4]\n",
    "plt.scatter(df1.YearsExperience, df1['Salary'],color='green')\n",
    "plt.scatter(df2.YearsExperience, df2['Salary'],color='red')\n",
    "plt.scatter(df3.YearsExperience, df3['Salary'],color='black')\n",
    "plt.scatter(df4.YearsExperience, df4['Salary'],color='blue')\n",
    "plt.scatter(df5.YearsExperience, df5['Salary'],color='purple')\n",
    "plt.xlabel('YearsExperience')\n",
    "plt.ylabel('Salary')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "f81w__fxsbdp"
   },
   "source": [
    "## Normalization and then again check"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "D6H77wGlEnCz",
    "outputId": "8d876e6a-3533-4ae3-effa-684345613a62"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>YearsExperience</th>\n",
       "      <th>Salary</th>\n",
       "      <th>cluster</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.015845</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.016129</td>\n",
       "      <td>0.083296</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.032258</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.072581</td>\n",
       "      <td>0.056952</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.088710</td>\n",
       "      <td>0.021232</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.145161</td>\n",
       "      <td>0.185887</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.153226</td>\n",
       "      <td>0.220369</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.169355</td>\n",
       "      <td>0.164291</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.169355</td>\n",
       "      <td>0.262587</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.209677</td>\n",
       "      <td>0.191263</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.225806</td>\n",
       "      <td>0.250526</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.233871</td>\n",
       "      <td>0.177551</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.233871</td>\n",
       "      <td>0.188983</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.241935</td>\n",
       "      <td>0.190202</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.274194</td>\n",
       "      <td>0.229815</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.306452</td>\n",
       "      <td>0.296921</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.322581</td>\n",
       "      <td>0.278157</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.338710</td>\n",
       "      <td>0.445839</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.387097</td>\n",
       "      <td>0.428883</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.395161</td>\n",
       "      <td>0.552509</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>0.459677</td>\n",
       "      <td>0.530865</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>0.483871</td>\n",
       "      <td>0.595101</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>0.548387</td>\n",
       "      <td>0.624875</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>0.572581</td>\n",
       "      <td>0.747842</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0.612903</td>\n",
       "      <td>0.704779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0.637097</td>\n",
       "      <td>0.666945</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>0.677419</td>\n",
       "      <td>0.778874</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>0.685484</td>\n",
       "      <td>0.736273</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>0.741935</td>\n",
       "      <td>0.832170</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>0.758065</td>\n",
       "      <td>0.827069</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>0.814516</td>\n",
       "      <td>0.880866</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>0.838710</td>\n",
       "      <td>0.875076</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>0.903226</td>\n",
       "      <td>0.894824</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>0.951613</td>\n",
       "      <td>0.962746</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    YearsExperience    Salary  cluster\n",
       "0          0.000000  0.015845        4\n",
       "1          0.016129  0.083296        4\n",
       "2          0.032258  0.000000        4\n",
       "3          0.072581  0.056952        4\n",
       "4          0.088710  0.021232        4\n",
       "5          0.145161  0.185887        0\n",
       "6          0.153226  0.220369        0\n",
       "7          0.169355  0.164291        0\n",
       "8          0.169355  0.262587        0\n",
       "9          0.209677  0.191263        0\n",
       "10         0.225806  0.250526        0\n",
       "11         0.233871  0.177551        0\n",
       "12         0.233871  0.188983        0\n",
       "13         0.241935  0.190202        0\n",
       "14         0.274194  0.229815        0\n",
       "15         0.306452  0.296921        0\n",
       "16         0.322581  0.278157        0\n",
       "17         0.338710  0.445839        2\n",
       "18         0.387097  0.428883        2\n",
       "19         0.395161  0.552509        2\n",
       "20         0.459677  0.530865        2\n",
       "21         0.483871  0.595101        2\n",
       "22         0.548387  0.624875        2\n",
       "23         0.572581  0.747842        1\n",
       "24         0.612903  0.704779        1\n",
       "25         0.637097  0.666945        1\n",
       "26         0.677419  0.778874        1\n",
       "27         0.685484  0.736273        1\n",
       "28         0.741935  0.832170        3\n",
       "29         0.758065  0.827069        3\n",
       "30         0.814516  0.880866        3\n",
       "31         0.838710  0.875076        3\n",
       "32         0.903226  0.894824        3\n",
       "33         0.951613  0.962746        3\n",
       "34         1.000000  1.000000        3"
      ]
     },
     "execution_count": 15,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scaler=MinMaxScaler()\n",
    "scaler.fit(df[['Salary']])\n",
    "df['Salary']=scaler.transform(df[['Salary']])\n",
    "scaler.fit(df[['YearsExperience']])\n",
    "df['YearsExperience']=scaler.transform(df[['YearsExperience']])\n",
    "\n",
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "0s7kGdAGEnCz",
    "outputId": "07278e7f-cfa7-4121-962f-71f7c9daaac7"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.24599877930393588\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.21469464378831662\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 0.21469464378831662\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.24976734481600707\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.2340310975743367\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 0.21368181551259902\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 3, inertia 0.21368181551259902\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.276907403808879\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.24463440390283883\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 0.2154232730708973\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 3, inertia 0.2154232730708973\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.21469464378831662\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.21469464378831662\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.24463440390283883\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.2154232730708973\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 0.2154232730708973\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.2154232730708973\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.2154232730708973\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.2154232730708973\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.2154232730708973\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.4307209532375872\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.4233023757955806\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 0.4233023757955806\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.2608751054662088\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.21469464378831662\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 0.21469464378831662\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n",
      "Initialization complete\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 0, inertia 0.2451278190383588\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 1, inertia 0.21368181551259902\n",
      "start iteration\n",
      "done sorting\n",
      "end inner loop\n",
      "Iteration 2, inertia 0.21368181551259902\n",
      "center shift 0.000000e+00 within tolerance 8.990979e-06\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,\n",
       "       2, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4], dtype=int32)"
      ]
     },
     "execution_count": 16,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "km=KMeans(n_clusters=5, init='k-means++',max_iter=100,verbose=True)\n",
    "y_predicted=km.fit_predict(df[['YearsExperience','Salary']])\n",
    "y_predicted"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 297
    },
    "id": "NSLvhEcuEnCz",
    "outputId": "63aae2f7-f85e-48de-9625-d5dcd1c0ff24"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Salary')"
      ]
     },
     "execution_count": 17,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAZ+ElEQVR4nO3dfZBcV3nn8e9vZBmvwB5SkZICSzPjBLkqxkqwazAGssREQGQTS0l4sVXDEogrk0DsLTZAxampNVjs1C5xQbTZQMxAHJNk4hdMXsagoN0V9po4MdYYg2WL2FFszViGwuJlZ3czOJKtZ/+4t+3WuKe7Z7pv3773/j5VU+q+90z3cy2rnz7nPOdcRQRmZlZdA3kHYGZm+XIiMDOrOCcCM7OKcyIwM6s4JwIzs4o7Je8AVmr9+vUxMjKSdxhmZoVy3333fTciNjQ6V7hEMDIywuzsbN5hmJkViqS55c55aMjMrOKcCMzMKs6JwMys4pwIzMwqzonAzKziMksEkm6Q9KSkB5c5L0l/IOmQpAcknZ9VLGZmRTY9DSMjMDCQ/Dk93d3Xz7JHcCOwrcn5i4HN6c848EcZxmJmVkjT0zA+DnNzEJH8OT7e3WSQWSKIiLuA7zdpsgP400jcA7xY0kuyisfMrIgmJmBx8eRji4vJ8W7Jc47gTODxuudH0mPPI2lc0qyk2aNHj/YkODOzfjA/v7Lj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RT0naDNxEstEeJPu8nxsRj0l6C/CtiHgzgKTBuveZlvTD9PH/iIgPAuPA3ZIeI1nNemFd+3UR8QpJrwNuINnnaGKZ+Gpx/HREfF8n3xjpCpItA14p6QXp+/339Nx5wMtJtlm+G3itpHuBW4DLImK/pDOAHy73Oun+Q2YncSKwQomIf5F0C/D/gLcDl0r6QHr6NGCI5IPyDyW9gmSbhbPrXuLeug/DA8DHJH0U+EJEfKWu3djSoaGI+I6ka4A7gF+OiPo9429K29wl6Yz0g/9NwPYG8UGSXBrtOf8m4KclvTV9PkiyadyxNPYjAJK+DoyQbKH+7YjYn77//0nPL/c6TgT2PE4EVkQn0h8Bb4mIh+tPSvow8B3gZ0iGP+tvSvMvtQcR8YiSexZcAvwnSfsiYleL995CslPtS5ccXzrZFk3ie1V9HEsIuCoi9i75nYuA+h1jn6H5v9+Gr2PWiOcIrMj2AlfVjZWflx4fJPmWfAL4dySblT2PpJcCixHx5ySb8jW992s69n8xyRDNBySdVXf6srTNz5IMySw0ia/VNb1H0tr0d86W9MIm7R8GXiLplWn705Vsrb7S17EKc4/AiuwjwG7gASU3onkM+EXgk8Dn04ndL7H8t+8twHWSTgDHSe7lXFM/R/Bd4M3Ap4F3R8S3JL0fuEHSz6dtnpJ0P8kukb/WIr5mPkMy5PO1NIEcBX5pucYRcSyd5P5vkv4NyfzAG1b6OlZtLh8161Avy03NsuChITOzinOPwMys4twjMDOrOCcCM7OKcyIwM6s4JwIzs4pzIjAzq7j/D3kvLoFAp0UyAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light",
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df1=df[df.cluster==0]\n",
    "df2=df[df.cluster==1]\n",
    "df3=df[df.cluster==2]\n",
    "df4=df[df.cluster==3]\n",
    "df5=df[df.cluster==4]\n",
    "plt.scatter(df1.YearsExperience, df1['Salary'],color='green')\n",
    "plt.scatter(df2.YearsExperience, df2['Salary'],color='red')\n",
    "plt.scatter(df3.YearsExperience, df3['Salary'],color='black')\n",
    "plt.scatter(df4.YearsExperience, df4['Salary'],color='blue')\n",
    "plt.scatter(df5.YearsExperience, df5['Salary'],color='purple')\n",
    "plt.xlabel('YearsExperience')\n",
    "plt.ylabel('Salary')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "0XcrjJDtsnhX"
   },
   "source": [
    "## Cluster Centroids"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "bJ3J8xpSEnC0",
    "outputId": "e7c176fb-93f3-47a5-a4ab-599c1b9849d0"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.22379032, 0.21971268],\n",
       "       [0.66935484, 0.75627898],\n",
       "       [0.43548387, 0.5296787 ],\n",
       "       [0.04193548, 0.03546504],\n",
       "       [0.9016129 , 0.92270234]])"
      ]
     },
     "execution_count": 18,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "km.cluster_centers_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 297
    },
    "id": "qXxAiISrEnC0",
    "outputId": "61732b04-0857-4436-9c72-e8b5616ceb08"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x7f9eb3b23650>"
      ]
     },
     "execution_count": 19,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAbrUlEQVR4nO3df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ZuJlkoz1I9nk/IyIel/R24AcR8TYASSNV71OR9LP08f+MiI8Ck8A9kh4nWc16TtX5wxHxGklvAm4k2edoqkF8y3G8OiKe1tE3RrqUZMuA10p6Sfp+/yM9dibwKpJtlu8B3ijpPuBW4MKI2CPpBOBnjV4n3X/I7ChOBJYrEfH3km4F/g54F3CBpI+kh48DRkk+KD8r6TUk2yycVvUS91V9GO4FPi3pk8DXI+JbVedN1A4NRcSPJF0F3An8y4io3jP+5vScuyWdkH7wvxXYXic+SJJLvT3n3wq8WtI70ucjJJvGPZvGfgBA0neBEskW6j+MiD3p+/9terzR6zgR2Is4EVgeHUn/CHh7RDxSfVDSx4EfAb9EMvxZfVOav19+EBGPKrlnwfnAf5S0OyKuWeG9t5DsVHtSTXvtZFs0ie911XHUEHBFROyq+Z1zgeodY5+j+b/fuq9jVo/nCCzPdgFXVI2Vn5m2j5B8Sz4C/GuSzcpeRNJJwFJEfJlkU76m935Nx/7PIxmi+YikU6sOX5ie88skQzKLTeJb6ZreL+nY9HdOk/TSJuc/ArxC0mvT849XsrX6al/HCsw9AsuzTwDXAQ8quRHN48A/Bz4PfDWd2P1zGn/73gJcK+kIcIjkXs7LqucIfgy8DbgBeF9E/EDSh4EbJf1aes4zkh4g2SXyN1aIr5kvkgz5fCdNIAeBf9Ho5Ih4Np3k/q+Sfo5kfuDNq30dKzaXj5q1qZvlpmZZ8NCQmVnBuUdgZlZw7hGYmRWcE4GZWcE5EZiZFZwTgZlZwTkRmJkV3P8H/AJj1Z5eLNAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light",
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df1=df[df.cluster==0]\n",
    "df2=df[df.cluster==1]\n",
    "df3=df[df.cluster==2]\n",
    "df4=df[df.cluster==3]\n",
    "df5=df[df.cluster==4]\n",
    "plt.scatter(df1.YearsExperience, df1['Salary'],color='green')\n",
    "plt.scatter(df2.YearsExperience, df2['Salary'],color='red')\n",
    "plt.scatter(df3.YearsExperience, df3['Salary'],color='black')\n",
    "plt.scatter(df4.YearsExperience, df4['Salary'],color='blue')\n",
    "plt.scatter(df5.YearsExperience, df5['Salary'],color='purple')\n",
    "plt.xlabel('YearsExperience')\n",
    "plt.ylabel('Salary')\n",
    "plt.scatter(km.cluster_centers_[:,0],km.cluster_centers_[:,1],color='yellow')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "EvZ0OYekstVb"
   },
   "source": [
    "## Sum of Square Error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "id": "EDenEChVEnC0"
   },
   "outputs": [],
   "source": [
    "k_rng=range(1,10)\n",
    "sse=[]\n",
    "for k in k_rng:\n",
    "    km=KMeans(n_clusters=k,init='k-means++')\n",
    "    km.fit(df[['YearsExperience','Salary']])\n",
    "    sse.append(km.inertia_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "JXPVlnE-EnC1",
    "outputId": "2bd21e27-d926-4b71-c6a5-bef652c4d04e"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[6.293685484541874,\n",
       " 1.292690919141886,\n",
       " 0.6527227565513628,\n",
       " 0.4101141952961812,\n",
       " 0.21368181551259902,\n",
       " 0.15226682764323596,\n",
       " 0.12182725552641988,\n",
       " 0.08849338117507208,\n",
       " 0.0759704313741079]"
      ]
     },
     "execution_count": 21,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sse"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "N0ED_rACs4b8"
   },
   "source": [
    "## Plot the SSE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 297
    },
    "id": "jxbEV7RoEnC1",
    "outputId": "5a4bb2c7-260e-4d38-9437-75213cf0abb0"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f9ea9a34e10>]"
      ]
     },
     "execution_count": 22,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEGCAYAAABvtY4XAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3dfXAcd53n8fd3ZvRkPY8tO7ZleyZ+yLMTG0khJARIIBcWFvbCHg8FHAt7m6XIbiXs7VJALUVxd1UH1MLCsUcgBALZheQghIUNEAIhEMKDbdlx7CQOcfBDLNuxZcuWJT/oab73x7Rk2chWy1ar5+HzqpqamVbP9Kdcybd7vt39+5m7IyIipScRdwAREYmGCryISIlSgRcRKVEq8CIiJUoFXkSkRKXiDjDenDlzPJPJxB1DRKRorF+//oC7t0z0t4Iq8JlMhs7OzrhjiIgUDTPbeaa/qUUjIlKiVOBFREqUCryISIlSgRcRKVEq8CIiJUoFXkSkRKnAi4iUqKIv8APDI3zpl3/gV1u7444iIlJQir7AVyYTfOXxbfz7k3vijiIiUlCKvsCbGW2ZZtbt6Ik7iohIQSn6Ag/QnknzYs8xXuo9EXcUEZGCURIF/ursbADW6iheRGRMSRT4S+bXU1uZZN12FXgRkVElUeBTyQSrl6gPLyIyXqQF3syazOwBM3vOzLaY2TVRbasjk+b3+/o4fGwwqk2IiBSVqI/gPw887O4XA1cCW6LaUEc2jTt07jgU1SZERIpKZAXezBqB64GvArj7oLsfjmp7Vy5qojKZUJtGRCQQ5RF8FugG7jGzJ83sbjOrjWpj1RVJVrY26koaEZFAlAU+BawG7nT3VcBR4MOnr2Rmt5pZp5l1dnef33AD7dk0m7t6OTY4fF7fIyJSC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+4u5XkZ9hqyP4iRgrM3sjsN/d18ed5Qyuc/fVwOuB24K2YNxSwGrgTndfBRwFPhxvpJOCltGbgO/EnQXAzJqBN5PfMS4Aas3sXfGmAnffAnwKeIR8e2YjMDJd368CH5Ggx/1d4Jvu/mDceU4X/Jx/DLg57izAtcCbgl73/cANZvZv8UY6KTj6w933A98j3y+NWxfQNe4X2APkC36heD2wwd33xR0k8Fpgu7t3u/sQ8CDwipgzAeDuX3X3l7n79cAh4Pnp+m4V+AgEJzO/Cmxx98/GnWeUmbWYWVPwugZ4HfBcvKnA3T/i7q3uniH/s/7n7h770RWAmdUGJ8oJWiA3kf9ZHSt3fwnYZWYXBYtuBGI9iX+ad1Ag7ZnAi8DLzWxW8P/njeTPjcXOzOYGz4vJ99+/NV3fHemMTjPBzO4DXg3MMbMu4OPu/tV4U3Et8G5gc9DvBvhoMMNVnOYD3wiubkR57vAAAAEgSURBVEgA33b3groksQDNA76XrwmkgG+5+8PxRhrzt8A3g3bINuC9MecBxnaErwP+Ou4so9x9jZk9AGwAhoEnKZxhC75rZrOBIeC26TxZXvSXSYqIyMTUohERKVEq8CIiJUoFXkSkRKnAi4iUKBV4EZESpQIvchZmlimkkUpFpkIFXkSkRKnAi4RkZhcGA3u1x51FJIyiv5NVZCYEQwLcD/yFuz8Vdx6RMFTgRSbXAnwfuCXuSVtEpkItGpHJ9ZIfrOq6uIOITIWO4EUmNwj8Z+AnZtbv7tM22p9IlFTgRUJw96PBxCQ/DYr8D+LOJDIZjSYpIlKi1IMXESlRKvAiIiVKBV5EpESpwIuIlCgVeBGREqUCLyJSolTgRURK1P8H6zBITR+8Vu4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light",
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.xlabel('k')\n",
    "plt.ylabel('sum of square error')\n",
    "plt.plot(k_rng,sse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "8na1sMNvEnC3",
    "outputId": "2a9b215e-5140-40dd-b8a2-9fec0cc7cf97"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['K-means++_model.pkl']"
      ]
     },
     "execution_count": 23,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import joblib\n",
    "joblib.dump(km,'K-means++_model.pkl')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "fv1I8H1mq53L"
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "include_colab_link": true,
   "name": "Unsupervised Learning .ipynb",
   "provenance": [],
   "toc_visible": true
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
